<template>
	<view class="page">
		<z-paging ref="paging" v-model="list" @query="getList">
			<template #top>
				<uni-nav-bar ref="navBar" fixed statusBar title="核销记录明细" :border="false" backgroundColor="#ffffff"
					@clickLeft="goBack">
					<template v-slot:left>
						<image src="@/static/svg/publicSvg/icon-back.svg" />
					</template>
				</uni-nav-bar>
			</template>
		
			<view class="detail-box" v-for="detail in list" :key="detail.id">
				<view class="fs-12">
					<view class="flex justify-between item-center mb-12">
						<view>订单编号：</view>
						<view @click="copy(detail.subOrderNo)" class="gary-color">{{ detail.subOrderNo }}<text class="fs-8 ml-2 color-secondary-info">复制</text></view>
					</view>
					<view class="flex justify-between item-center mb-12">
						<view>核销时间：</view>
						<view class="gary-color">{{ detail.verifyTime }}</view>
					</view>
					<view class="flex justify-between item-center">
						<view>核销渠道：</view>
						<view class="gary-color">
							<span v-if="detail.verifyType === 0">系统</span>
							<span v-if="detail.verifyType === 1">票付通</span>
						</view>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script setup>
	import {ref} from 'vue'
	import {onLoad} from '@dcloudio/uni-app'
	import { pageVerifyGoodsDetail } from '@/api/order.js';
	const goBack = () => {
		if(getCurrentPages().length === 1) {
			uni.reLaunch({
				url: '/homePages/pages/home/home'
			})
			return
		}
		uni.navigateBack()
	}
	let params = ref({
		pageNum: 1,
		pageSize: 15
	})
	const triggered = ref(false)
	let list = ref([])
	let total = ref(0)
	let refreshFlag = ref(false)
	// 获取列表
	const paging = ref()
	const getList = async (num) => {
		triggered.value = true
		params.value.pageNum = num
		uni.showLoading()
		let result = await pageVerifyGoodsDetail({
			...params.value
		})
		if (result) {
			paging.value.complete(result.list)
		}
		uni.hideLoading()
		triggered.value = false
		refreshFlag.value = false
	}
	const reFresh = () => {
		list.value = []
		params.value.pageNum = 1
		getList(1)
	}
	const onRestore = () => {
		triggered.value = false; // 需要重置
	}
	const onRefresh = () => {
		triggered.value = true
		reFresh()
	}
	const copy = (text) => {
		uni.setClipboardData({
			data: text,
			success: function () {
				uni.showToast({
					icon:'none',
					title:'复制成功'
				})
			}
		});
	
	}
	onLoad((query) => {
		if(query.id) {
			params.value.activeGoodsId = query.id
		}
		if(query.no) {
			params.value.subOrderNo = query.no
		}
		reFresh()
	})
</script>

<style lang="scss" scoped>
	.detail-box{
		margin: 10px 20px;
		box-sizing: border-box;
		padding: 10px 14px;
		background-color: #ffffff;
		border-radius: 8px;
	}
	.gary-color{
		color: rgba(51, 51, 51, 0.6);
	}
</style>
